package nl.infodation.emr.pricingservice.valuesimporter;

import java.util.Arrays;

public class CSVFormat {

    private String charset;
    private char fieldDelimiter;
    private char textDelimiter;
    private char lineTerminator;
    private char[] ignoreCharacters;

    /**
     * Construct a standard CSV format
     */
    public CSVFormat() {
    	charset = "UTF-8";
    	fieldDelimiter = '\t';
    	textDelimiter = '"';
    	lineTerminator = '\n';
    	ignoreCharacters = new char[]{'\r'};
    }

    /**
     * is ignored characters
     * @param character
     * @return
     */
    public boolean isIgnored(final char character) {
        return Arrays.binarySearch(getIgnoreCharacters(), character) >= 0;
    }

	public String getCharset() {
		return charset;
	}

	public void setCharset(final String charset) {
		this.charset = charset;
	}


	public char getFieldDelimiter() {
		return fieldDelimiter;
	}

	public void setFieldDelimiter(final char fieldDelimiter) {
		this.fieldDelimiter = fieldDelimiter;
	}

	public char getTextDelimiter() {
		return textDelimiter;
	}

	public void setTextDelimiter(final char textDelimiter) {
		this.textDelimiter = textDelimiter;
	}

	public char getLineTerminator() {
		return lineTerminator;
	}

	public void setLineTerminator(final char lineTerminator) {
		this.lineTerminator = lineTerminator;
	}

	public char[] getIgnoreCharacters() {
		return ignoreCharacters.clone();
	}

	public void setIgnoreCharacters(final char[] ignoreCharacters) {
		this.ignoreCharacters = ignoreCharacters.clone();
	}
}